package logic

import (
	"book-hub/bookrpc/bookrpc"
	"context"

	"book-hub/api/internal/svc"
	"book-hub/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type NovelCommentLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewNovelCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *NovelCommentLogic {
	return &NovelCommentLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *NovelCommentLogic) NovelComment(req *types.NovelCommentRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	comment, err := l.svcCtx.BookRpc.NovelComment(l.ctx, &bookrpc.NovelCommentRequest{
		NovelId: req.NovelId,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	}
	return &types.Response{
		Message: "小说添加成功",
		Code:    200,
		Data:    comment,
	}, nil
}
